import React,{Component} from "react";
import './index.css'

export default class Item extends Component{

 
    constructor(props) {
        super(props)
        this.state = {
           text:'',
           gloab: true
        }
       
        
    }
    
  componentDidMount() {
      console.log("item组件挂载完毕")
      console.log("父传子："+this.props.txt)
  }
  

  handleDelete = (e) => {
      return () => {
        this.props.onHandleDelete(e)
      }
  }

    render() {
        return(
            <div>
                <ul>
                    {
                        this.props.txt.map(item => {
                            return(
                                <li key={item}>
                                   {item}
                                   <button className="btn1" onClick={this.handleDelete(item)}>删除</button>
                                </li>
                            )
                        })
                    }
                </ul>
            </div>
        )
    }
}